# Contributor: Simon Frankenberger <simon-alpine@fraho.eu>
# Maintainer: Simon Frankenberger <simon-alpine@fraho.eu>
pkgname=java-asmtools
_pkgver=8.0-b09
pkgver=${_pkgver/-b/.}
pkgrel=0
pkgdesc="The AsmTools open source project is used to develop tools for the production of proper and improper Java '.class' files"
url="https://github.com/openjdk/asmtools"
# riscv64: no java
# s390x: FTBFS due to SIGFPE (see #12275)
# armhf / armv7 / x86 / ppc64le: requires java 17
arch="noarch !riscv64 !armhf !armv7 !x86 !ppc64le !s390x"
license="GPL-2.0"
makedepends="java-jdk"
options="!check" # this package has no tests
subpackages="$pkgname-doc:_doc"
source="https://github.com/openjdk/asmtools/archive/$_pkgver/asmtools-$_pkgver.tar.gz
	https://archive.apache.org/dist/ant/binaries/apache-ant-1.9.13-bin.zip

	java-version-check.patch
	"
builddir="$srcdir/asmtools-$_pkgver"

_ant_home="$srcdir"/apache-ant-1.9.13/

build() {
	cd "$builddir/build"

	# fix the build target directory
	sed -i "s@^BUILD_DIR.\+@BUILD_DIR = $builddir/target@" build.properties

	$_ant_home/bin/ant
}

package() {
	_destdir="$pkgdir/usr/share/java/asmtools"
	mkdir -p "$_destdir"
	cp -r \
		$builddir/target/binaries/lib \
		$builddir/target/binaries/LICENSE \
		"$_destdir"
}

_doc() {
	_destdir="$subpkgdir/usr/share/java/asmtools"
	mkdir -p "$_destdir"
	cp -r \
		$builddir/target/binaries/doc \
		$builddir/target/binaries/README.html \
		"$_destdir"
}

sha512sums="
27d4378061d0c703d0220b35b75ce67bcd20dce3f0339cdbd68e8396cf647719ae029720081abac22e186ae9d5ed5c1fb4050adea30f3ef855586eaacba1dca7  asmtools-8.0-b09.tar.gz
873062cf789e1572ec4ef3cdbb15c0d3a57e5a0794068591565367d4cec15b9f9a24f59734a85170d61b23eb9288d6bafd35a9ae2b015b09c7a175e344cb4e1c  apache-ant-1.9.13-bin.zip
e6687969df9d1386c9d7e2948f0f08f1c447f14d30281372f29efb47a894a709b1a901429087e5e7cb69daa9f3e935f3613750239e9eb848ddaf736b4affd056  java-version-check.patch
"
